package com.mdd.front.controller.order;

import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import com.mdd.front.service.order.IOrderAcceptDetailsService;
import com.mdd.front.validate.common.IdValidate;
import com.mdd.front.validate.common.PageValidate;
import com.mdd.front.validate.order.OrderAcceptDetailsCreateValidate;
import com.mdd.front.validate.order.OrderAcceptDetailsSearchValidate;
import com.mdd.front.validate.order.OrderAcceptDetailsUpdateValidate;
import com.mdd.front.vo.order.OrderAcceptDetailsDetailVo;
import com.mdd.front.vo.order.OrderAcceptDetailsListedVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/orderAcceptDdetails")
@Api(tags = "接单详情信息管理")
public class OrderAcceptDetailsController {

    @Resource
    IOrderAcceptDetailsService iOrderAcceptDetailsService;

    @GetMapping("/list")
    @ApiOperation(value="接单详情信息列表")
    public AjaxResult<PageResult<OrderAcceptDetailsListedVo>> list(@Validated PageValidate pageValidate,
                                                                   @Validated OrderAcceptDetailsSearchValidate searchValidate) {
        PageResult<OrderAcceptDetailsListedVo> list = iOrderAcceptDetailsService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="接单详情信息详情")
    public AjaxResult<OrderAcceptDetailsDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        OrderAcceptDetailsDetailVo detail = iOrderAcceptDetailsService.detail(id);
        return AjaxResult.success(detail);
    }

    @PostMapping("/add")
    @ApiOperation(value="接单详情信息新增")
    public AjaxResult<Object> add(@Validated @RequestBody OrderAcceptDetailsCreateValidate createValidate) {
        iOrderAcceptDetailsService.add(createValidate);
        return AjaxResult.success();
    }

    @PostMapping("/edit")
    @ApiOperation(value="接单详情信息编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody OrderAcceptDetailsUpdateValidate updateValidate) {
        iOrderAcceptDetailsService.edit(updateValidate);
        return AjaxResult.success();
    }

    @PostMapping("/del")
    @ApiOperation(value="接单详情信息删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iOrderAcceptDetailsService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
